styleproperty: Change _css_value_to_string()
authorBenjamin Otte <otte@redhat.com>
Mon, 23 May 2011 05:16:17 +0000 (07:16 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 2 Jun 2011 00:03:50 +0000 (02:03 +0200)
Name it _gtk_style_property_print_value() and actually pass it the style
property. This way, we can later change it to use custom print functions
for different style properties.

gtk/gtkcssprovider.c
gtk/gtkstyleproperty.c
gtk/gtkstylepropertyprivate.h

index 2b6e181e9e17eb4c7425e036753a8c7f61ac5f96..5cb8d8b58fa34e7de4f0c33846c7a4fcabd9bd78 100644 (file)
@@ -2976,7 +2976,6 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
                        GString             *str)
 {
   GList *keys, *walk;
-  char *s;
 
   _gtk_css_selector_print (ruleset->selector, str);
 
@@ -2996,9 +2995,7 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
           g_string_append (str, "  ");
           g_string_append (str, prop->pspec->name);
           g_string_append (str, ": ");
-          s = _gtk_css_value_to_string (value);
-          g_string_append (str, s);
-          g_free (s);
+          _gtk_style_property_print_value (prop, value, str);
           g_string_append (str, ";\n");
         }
 
index fc3c8dab23439d2a188ed4d923782abae3327b37..3c4462367f6682248d0672315b16692043158087 100644 (file)
@@ -1403,8 +1403,10 @@ _gtk_css_value_parse (GValue       *value,
   return (*func) (parser, base, value);
 }
 
-char *
-_gtk_css_value_to_string (const GValue *value)
+void
+_gtk_style_property_print_value (const GtkStyleProperty *property,
+                                 const GValue           *value,
+                                 GString                *string)
 {
   PrintFunc func;
 
@@ -1416,14 +1418,15 @@ _gtk_css_value_to_string (const GValue *value)
     func = g_hash_table_lookup (print_funcs,
                                 GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));
 
-  if (func)
+  if (func == NULL)
     {
-      GString *string = g_string_new (NULL);
-      func (value, string);
-      return g_string_free (string, FALSE);
+      char *s = g_strdup_value_contents (value);
+      g_string_append (string, s);
+      g_free (s);
+      return;
     }
-
-  return g_strdup_value_contents (value);
+  
+  func (value, string);
 }
 
 gboolean
index a1d222ecf5afaba58cf05c4e7f4c910c3a894c57..8ffe0adf8b3c278f09a6c3d4d6af4a32351a66e0 100644 (file)
@@ -59,7 +59,9 @@ void                     _gtk_style_property_pack          (const GtkStyleProper
 gboolean                _gtk_css_value_parse              (GValue        *value,
                                                            GtkCssParser  *parser,
                                                            GFile         *base);
-char *                  _gtk_css_value_to_string          (const GValue  *value);
+void                     _gtk_style_property_print_value   (const GtkStyleProperty *property,
+                                                            const GValue           *value,
+                                                            GString                *string);
 
 G_END_DECLS